home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Snippets / String Rotation / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-09  |  1.9 KB  |  79 lines  |  [TEXT/R*ch]

  1. /***
  2.  
  3.     This is a quickie example of how to use the GetRotatedStringBitmap function.
  4.     
  5.     This is also based on some Apple sample code, but has been modified slightly.
  6.     
  7.     - Guy Fullerton
  8.  
  9. ***/
  10.  
  11.  
  12. #include "GetRotatedStringBitmap.h"
  13.  
  14.  
  15. void main( void )
  16. {
  17.     WindowPtr                    window1;
  18.     WindowPtr                    window2;
  19.     BitMap                        destMap;
  20.     Rect                        windowRect;
  21.  
  22.     // do some toolbox initialization
  23.     InitGraf( &qd.thePort );
  24.     InitFonts();
  25.     FlushEvents( everyEvent, 0xFFFF );
  26.     InitWindows();
  27.     InitMenus();
  28.     TEInit();
  29.     InitDialogs( nil );
  30.     InitCursor();
  31.     
  32.     // create a window to hold the counter clockwise string
  33.     SetRect( &windowRect, 100, 100, 200, 200);
  34.     window1 = NewWindow( nil, &windowRect, "\p", true,
  35.         noGrowDocProc,(WindowPtr)-1, true, nil );
  36.     
  37.     // set up the font the way we want it
  38.     SetPort(window1);
  39.     TextFont(applFont);
  40.     TextSize(12);
  41.  
  42.     // rotate the string
  43.     GetRotatedStringBitmap( "\pFirst", &destMap, rotationDirection_CounterClockWise);
  44.     
  45.     // size the window so we're the same size as the bitmap
  46.     SizeWindow(window1,destMap.bounds.right,destMap.bounds.bottom,false);
  47.  
  48.     // draw the bitmap into the window
  49.     CopyBits( &destMap, &window1->portBits, &destMap.bounds,
  50.         &destMap.bounds, srcCopy, nil );
  51.  
  52.     // create a winow to hold the clockwise string
  53.     OffsetRect(&windowRect,(windowRect.right - windowRect.left ) + 40,0);
  54.     window2 = NewWindow( nil, &windowRect, "\p", true,
  55.         noGrowDocProc,(WindowPtr) (WindowPtr)-1, true, nil );
  56.  
  57.     // set up the font the way we want it
  58.     SetPort(window2);
  59.     TextFont(applFont);
  60.     TextFace(bold+outline);
  61.     TextSize(32);
  62.  
  63.     // rotate the string
  64.     GetRotatedStringBitmap( "\pBold", &destMap, rotationDirection_ClockWise);
  65.     
  66.     // size the window so we're the same size as the bitmap
  67.     SizeWindow(window2,destMap.bounds.right,destMap.bounds.bottom,false);
  68.  
  69.     // draw the bitmap into the window
  70.     CopyBits( &destMap, &window2->portBits, &destMap.bounds,
  71.         &destMap.bounds, srcCopy, nil );
  72.  
  73.     // wait til the user clicks the mouse button
  74.     while( !Button() );
  75.  
  76. }
  77.  
  78.  
  79.